package com.franklin.ideaplugin.easytesting.thread;

import java.util.concurrent.*;

/**
 * @author Ye Junhui
 * @since 2023/5/15
 */
public class EasyTestingThreadPool {

    /**
     * 业务线程池
     */
    private final static ThreadPoolExecutor bizThreadPool = new ThreadPoolExecutor(
            1,
            4,
            60L,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(2000),
            r -> {
                Thread thread = new Thread(r, "easy-testing-thread-" + r.hashCode());
                thread.setDaemon(true);
                return thread;
            },
            (r, executor) -> {
                throw new RuntimeException("easy-testing, EmbedServer bizThreadPool is EXHAUSTED!");
            });

    public static ThreadPoolExecutor getBizThreadPool(){
        return bizThreadPool;
    }
}
